<template>
  <div class="header">
    <!--内容区块-->
    <div class="content-wrapper" @click="showDetails()">
      <div class="avatar">
        <img width="64" height="64" :src="seller.avatar" alt="">
      </div>
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class="name">{{ seller.name }}</span>
        </div>
        <div class="description">{{ seller.description }}/ {{ seller.deliveryTime }}分钟送达</div>
        <div v-if="seller.supports" class="support">
          <span class="icon" :class="classMap[seller.supports[1].type]"></span>
          <span class="text">{{ seller.supports[0].description }}</span>
        </div>
        <div v-if="seller.supports" class="support-count">
          <span class="count">{{ seller.supports.length}}个</span>
          <i class="icon">&gt;</i>
        </div>
      </div>
    </div>
    <!--内容区块 end-->
    <div class="bulletin-wrapper" @click="showDetails()">
      <span class="bulletin-title"></span><span class="bulletin-text">{{ seller.bulletin }}</span>
      <i class="icon">></i>
    </div>
    <div class="header-bg"><img :src="seller.avatar" alt="" width="100%" height="100%"></div>
    <div class="details" v-show="datailsShow" transition="fade">
      <div class="details-wrapper clearfix">
        <div class="details-main">
          <h2 class="name">{{ seller.name }}</h2>
          <div class="star-wrapper">
            <star :size="48" :score="seller.score"></star>
          </div>
          <div class="title">
            <div class="line"></div>
            <div class="text">优惠信息</div>
            <div class="line"></div>
          </div>
          <ul v-if="seller.supports" class="supports">
            <li v-for="item in seller.supports" class="supports-item">
              <span class="icon" :class="classMap[seller.supports[$index].type]"></span>
              <span class="text">{{ item.description}}</span>
            </li>
          </ul>
          <div class="title">
            <div class="line"></div>
            <div class="text">商家公告</div>
            <div class="line"></div>
          </div>
          <div class="bulletin">
            <p class="content">{{seller.bulletin}}</p>
          </div>
        </div>
      </div>
      <div class="details-close" @click="hideDetails()">×</div>
    </div>
  </div>
</template>

<script>
  import Star from 'components/star/star'

  export default {
    props: {           //接收父组件传值
      seller: {
        type: Object
      }
    },
    data() {
      return {
        datailsShow: false
      }
    },
    created() {
      this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee']
    },
    methods: {
      showDetails() {
        this.datailsShow = true
      },
      hideDetails() {
        this.datailsShow = false
      }
    },
    components: {
      Star
    }
  }

</script>

<style lang="stylus" rel="stylesheet/stylus">
  @import '../../common/stylus/index.styl'
  .header
    position: relative
    color: #fff
    background-color: rgba(7, 17, 27, .5)
    overflow: hidden
    .content-wrapper
      position: relative
      padding: 24px 12px 18px 24px
      font-size: 0                   //去除默认的间隙
      vertical-align: top
      .avatar
        display: inline-block
        img
          border-radius: 2px
      .content
        display: inline-block
        font-size: 14px
        margin-left: 16px
      .title
        margin: 2px 0 8px 0
        .brand
          display: inline-block
          vertical-align: top
          width: 30px
          height: 18px
          bg-image("brand")
          background-size: 30px 18px
        .name
          margin-left: 6px
          font-size: 16px
          font-weight: blod
          line-height: 18px
      .description
        margin-bottom: 10px
        font-size: 12px
        line-height: 12px
        font-weight: 200
      .support-count
        position: absolute
        right: 12px
        bottom: 18px
        height: 24px
        padding: 0 8px
        font-size: 10px
        line-height: 12px
        color: rgb(255, 255, 255)
        border-radius: 14px
        background-color: rgba(0, 0, 0, .2)
        text-align: center
        .count
          line-height: 24px
          margin-right: 4px
        .icon
          font-style: normal
      .support
        margin-bottom: 4px
        .icon
          display: inline-block
          vertical-align: top
          width: 12px
          height: 12px
          margin-right: 4px
          background-size: 12px 12px
          background-repeat: no-repeat
          &.decrease
            bg-image("decrease_1")
          &.discount
            bg-image("discount_1")
          &.guarantee
            bg-image("guarantee_1")
          &.invoice
            bg-image("invoice_1")
          &.special
            bg-image("special_1")
        .text
          vertical-align: top
          font-size: 10px
          font-weight: 200
          line-height: 12px
    .bulletin-wrapper
      position: relative
      height: 28px
      line-height: 28px
      padding: 0 22px 0 12px
      background: rgba(7, 17, 27, .2)
      color: rgb(255, 255, 255)
      overflow: hidden
      white-space: nowrap
      text-overflow: ellipsis
      .bulletin-title
        display: inline-block
        vertical-align: top
        width: 22px
        height: 12px
        margin-top: 9px
        bg-image('bulletin')
        background-size: 22px 12px
        background-repeat: no-repeat
      .bulletin-text
        margin: 0 4px
        font-size: 10px
      .icon
        position: absolute
        right: 12px
        top: 0
        font-size: 10px
    .header-bg
      position: absolute
      top: 0
      left: 0
      width: 100%
      height: 100%
      z-index: -1
      filter: blur(10px)
    .details
      position: fixed
      top: 0
      left: 0
      width: 100%
      height: 100%
      background: rgba(7, 17, 27, .8)
      filter: bulr(10px)
      transition: all .4s
      z-index: 101
      &.fade-transition
        opacity: 1
        transition: opacity .4s
      &.fade-enter, &.fade-leave
        opacity: 0
        transition: opacity .4s
      .details-wrapper
        min-height: 100%
        width: 100%
        .details-main
          width: 80%
          margin: 0 auto
          margin-top: 64px
          padding-bottom: 64px
          .name
            line-height: 16px
            font-size: 16px
            font-weight: 700
            text-align: center
          .star-wrapper
            margin-top: 16px
            text-align: center
          .title
            display: flex
            margin: 28px 0 24px 0
            .line
              flex: 1
              border-top: 1px solid rgba(255, 255, 255, .2)
              position: relative
              top: 7px
            .text
              padding: 0 12px
              font-size: 14px
              line-height: 14px
              font-weight: 700
          .supports
            .supports-item
              padding: 0 12px
              margin-bottom: 12px
              font-size: 0
              &:last-child
                margin-bottom: 0
              .icon
                display: inline-block
                width: 16px
                height: 16px
                vertical-align: top
                margin-right: 6px
                background-size: 16px 16px
                background-repeat: no-repeat
                &.decrease
                  bg-image('decrease_2')
                &.discount
                  bg-image('discount_2')
                &.guarantee
                  bg-image('guarantee_2')
                &.invoice
                  bg-image('invoice_2')
                &.special
                  bg-image('special_2')
              .text
                font-size: 12px
          .bulletin
            font-size: 12px
            line-height: 24px
      .details-close
        position: relative
        width: 32px
        height: 32px
        margin: -64px auto 0 auto
        font-size: 40px
        clear: both
</style>
